package com.newture.lxz.controller;


import com.newture.lxz.controller.helper.Result;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import sun.security.util.Length;

import java.math.BigDecimal;
import java.sql.*;
import java.util.HashMap;
import java.util.Map;


@Controller
@RequestMapping("/lawyersfeecalculator")
@Validated
public class lawyersFeeCalculator {

    @GetMapping("/getProvinceList")
    @ResponseBody
    public Result getProvinceList(){
        String[] provinceList=new String[]{
                "北京市",
                "天津市",
                "福建省",
                "江西省",
                "河北省",
                "河南省",
                "海南省",
                "湖南省",
                "湖北省",
                "西藏自治区",
                "甘肃省",
                "青海省",
                "宁夏回族自治区",
                "山东省",
                "陕西省",
                "上海市",
                "江苏省",
                "浙江省",
                "安徽省",
                "山西省",
                "内蒙古自治区",
                "辽宁省",
        };
        Map<String,String> [] list=new Map[22];
        for(int i=0;i< list.length;i++){
            Map<String,String> m=new HashMap<String,String>();
            m.put("value",provinceList[i]);
            list[i]=m;
        }
    return Result.success(list);
    }
    @GetMapping("/lawyersfeecalc")
    @ResponseBody
    public Result lawyersfeecalc(
            @RequestParam(name = "province", required = true) String province,
            @RequestParam(name = "caseObject", required = true) String caseObject){
        System.out.println("province: "+province+"caseObject: "+caseObject);
        double caseFee=Double.parseDouble(caseObject);
        //province：省份；caseFee标的金额
        //链接数据库
        lawyersFeeRequest lyf = new lawyersFeeRequest(0,0,0,"n");
        double fee_low=0;
        double fee_mid=0;
        double fee_high=0;
        String basis="";
        switch(province){

            case "海南省":{
                return Result.success(new lawyersFeeCalculatorWithNoBasis());
            }
            case "西藏自治区":{
                return Result.success(new lawyersFeeCalculatorWithNoBasis());
            }

            case "甘肃省":{
                return Result.success(new lawyersFeeCalculatorWithNoBasis());
            }

            case "青海省":{
                return Result.success(new lawyersFeeCalculatorWithNoBasis());
            }

            case "宁夏回族自治区":{
                return Result.success(new lawyersFeeCalculatorWithNoBasis());
            }

//            case "福建省":{
//                if (caseFee <= 100000 ) {
//                    fee_low = 800;
//                    fee_high = 6000;
//                    fee_mid = (fee_low+fee_high)/2;
//                }
//                else if (caseFee > 100000 && caseFee <= 500000){
//                    fee_low = 800+(caseFee-100000)*0.04;
//                    fee_high = 6000+(caseFee-100000)*0.04;
//                    fee_mid = (fee_low+fee_high)/2;
//                }
//                else if (caseFee > 500000 && caseFee <= 1000000){
//                    fee_low = 16800+(caseFee-500000)*0.03;
//                    fee_high = 22000+(caseFee-500000)*0.03;
//                    fee_mid = (fee_low+fee_high)/2;
//                }
//                else if (caseFee > 1000000 && caseFee <= 5000000){
//                    fee_low = 31800+(caseFee-1000000)*0.02;
//                    fee_high = 37000+(caseFee-1000000)*0.02;
//                    fee_mid = (fee_low+fee_high)/2;
//                }
//                else if (caseFee > 5000000 && caseFee <= 10000000){
//                    fee_low = 111800+(caseFee-5000000)*0.012;
//                    fee_high = 117000+(caseFee-5000000)*0.012;
//                    fee_mid = (fee_low+fee_high)/2;
//                }
//                else if (caseFee > 10000000 && caseFee <= 50000000){
//                    fee_low = 171800+(caseFee-10000000)*0.007;
//                    fee_high = 177000+(caseFee-10000000)*0.007;
//                    fee_mid = (fee_low+fee_high)/2;
//                }
//                else if (caseFee > 50000000 ){
//                    fee_low = 451800+(caseFee-50000000)*0.005;
//                    fee_high = 457000+(caseFee-50000000)*0.005;
//                    fee_mid = (fee_low+fee_high)/2;
//                }
//                basis = "自2018.10.01，律师服务收费实行市场调节价。《福建省律师服务收费标准（试行）》（闽价服〔2013〕67号）（已失效，供参考）";
//            }break;
            case "江西省":{
                if (caseFee <= 50000 ) {
                    fee_low = 1000;
                    fee_high = 6000;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 50000 && caseFee <= 100000){
                    fee_low = 1000+(caseFee-50000)*0.015;
                    fee_high = 6000+(caseFee-50000)*0.05;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 100000 && caseFee <= 1000000){
                    fee_low = 1750+(caseFee-100000)*0.012;
                    fee_high = 8500+(caseFee-100000)*0.04;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 1000000 && caseFee <= 5000000){
                    fee_low = 12550+(caseFee-1000000)*0.01;
                    fee_high = 44500+(caseFee-1000000)*0.03;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 5000000 && caseFee <= 10000000){
                    fee_low = 52500+(caseFee-5000000)*0.005;
                    fee_high = 164500+(caseFee-5000000)*0.02;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 10000000 && caseFee <= 50000000){
                    fee_low = 77550+(caseFee-10000000)*0.002;
                    fee_high = 264500+(caseFee-10000000)*0.015;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 50000000 ){
                    fee_low = 157550+(caseFee-50000000)*0.001;
                    fee_high = 864500+(caseFee-50000000)*0.01;
                    fee_mid = (fee_low+fee_high)/2;
                }
                basis = "《江西省律师服务收费指导价标准（暂行）》（赣计价费字[2003]587号）";
            }break;
            case "山东省":{
                if (caseFee <= 10000 ) {
                    fee_low = 1000;
                    fee_high = 2000;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 10000 && caseFee <= 100000){
                    fee_low = 1000+(caseFee-10000)*0.05;
                    fee_high = 6000+(caseFee-10000)*0.06;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 100000 && caseFee <= 1000000){
                    fee_low = 5500+(caseFee-100000)*0.04;
                    fee_high = 7400+(caseFee-100000)*0.05;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 1000000 && caseFee <= 5000000){
                    fee_low = 41500+(caseFee-1000000)*0.03;
                    fee_high = 52400+(caseFee-1000000)*0.04;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 5000000 && caseFee <= 10000000){
                    fee_low = 161500+(caseFee-5000000)*0.02;
                    fee_high = 212400+(caseFee-5000000)*0.03;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 10000000 && caseFee <= 50000000){
                    fee_low = 261500+(caseFee-10000000)*0.01;
                    fee_high = 362400+(caseFee-10000000)*0.02;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 50000000 ){
                    fee_low = 661500+(caseFee-50000000)*0.005;
                    fee_high = 1162400+(caseFee-50000000)*0.01;
                    fee_mid = (fee_low+fee_high)/2;
                }
                basis = "自2017.08.15-2022.05.31，律师服务收费实行市场调节价。《山东省律师服务收费标准指导意见》（鲁律协〔2015〕24号）（已废止，供参考）";
            }break;
            case "河南省":{
                if (caseFee <= 100000 ) {
                    fee_low = 3000;
                    fee_high = 5000;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 100000 && caseFee <= 1000000){
                    fee_low = 3000+(caseFee-100000)*0.03;
                    fee_high = 5000+(caseFee-100000)*0.05;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 1000000 && caseFee <= 10000000){
                    fee_low = 30000+(caseFee-1000000)*0.02;
                    fee_high = 50000+(caseFee-1000000)*0.04;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 10000000 && caseFee <= 50000000){
                    fee_low = 210000+(caseFee-10000000)*0.01;
                    fee_high = 410000+(caseFee-10000000)*0.03;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 50000000 ){
                    fee_low = 610000+(caseFee-50000000)*0.005;
                    fee_high = 161000+(caseFee-50000000)*0.02;
                    fee_mid = (fee_low+fee_high)/2;
                }
                basis = "《河南省律师服务收费行业指导标准》";
            }break;
            case "湖北省":{
                if (caseFee <= 100000 ) {
                    fee_low = 600;
                    fee_high = 8000;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 100000 && caseFee <= 1000000){
                    fee_low = 600+(caseFee-100000)*0.01;
                    fee_high = 8000+(caseFee-100000)*0.05;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 1000000 && caseFee <= 5000000){
                    fee_low = 9600+(caseFee-1000000)*0.005;
                    fee_high = 53000+(caseFee-1000000)*0.03;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 5000000 && caseFee <= 10000000){
                    fee_low = 29600+(caseFee-5000000)*0.003;
                    fee_high = 173000+(caseFee-5000000)*0.02;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 10000000 && caseFee <= 50000000){
                    fee_low = 44600+(caseFee-10000000)*0.015;
                    fee_high = 273000+(caseFee-10000000)*0.02;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 50000000 ){
                    fee_low = 124600+(caseFee-50000000)*0.001;
                    fee_high = 873000+(caseFee-50000000)*0.01;
                    fee_mid = (fee_low+fee_high)/2;
                }
                basis = "自2018.12.01，律师服务收费实行市场调节价。《湖北省律师服务收费管理实施办法（暂行）》（鄂价房服〔2006〕258号）（已废止，供参考）";
            }break;
            case "湖南省":{
                if (caseFee <= 10000 ) {
                    fee_low = 3000;
                    fee_high = 10000;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 100000 && caseFee <= 500000){
                    fee_low = 3000+(caseFee-100000)*0.06;
                    fee_high = 10000+(caseFee-100000)*0.08;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 500000 && caseFee <= 5000000){
                    fee_low = 27000+(caseFee-500000)*0.04;
                    fee_high = 42000+(caseFee-500000)*0.06;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 5000000 && caseFee <= 20000000){
                    fee_low = 207000+(caseFee-5000000)*0.02;
                    fee_high = 312000+(caseFee-5000000)*0.04;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 20000000 && caseFee <= 100000000){
                    fee_low = 507000+(caseFee-20000000)*0.01;
                    fee_high = 912000+(caseFee-20000000)*0.02;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 100000000 ){
                    fee_low = 1307000+(caseFee-100000000)*0.005;
                    fee_high = 2512000+(caseFee-100000000)*0.01;
                    fee_mid = (fee_low+fee_high)/2;
                }
                basis = "《湖南省律师服务收费行业指导标准》";
            }break;

            case "陕西省":{
                if (caseFee <= 100000 ) {
                    fee_low = caseFee*0.08;
                    if (fee_low < 5000){
                        fee_low = 5000;
                    }
                    fee_high = caseFee*0.1;
                    if ( fee_high < 5000){
                        fee_high = 5000;
                    }
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 100000 && caseFee <= 500000){
                    fee_low = 8000+(caseFee-100000)*0.07;
                    fee_high = 10000+(caseFee-100000)*0.09;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 500000 && caseFee <= 1000000){
                    fee_low = 36000+(caseFee-500000)*0.06;
                    fee_high = 46000+(caseFee-500000)*0.08;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 1000000 && caseFee <= 5000000){
                    fee_low = 66000+(caseFee-1000000)*0.05;
                    fee_high = 86000+(caseFee-1000000)*0.07;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 5000000 && caseFee <= 10000000){
                    fee_low = 266000+(caseFee-5000000)*0.04;
                    fee_high = 366000+(caseFee-5000000)*0.06;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 10000000 && caseFee <= 50000000){
                    fee_low = 466000+(caseFee-10000000)*0.03;
                    fee_high = 666000+(caseFee-10000000)*0.05;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 50000000 && caseFee <= 100000000){
                    fee_low = 1666000+(caseFee-50000000)*0.02;
                    fee_high = 2666000+(caseFee-50000000)*0.04;
                    fee_mid = (fee_low+fee_high)/2;
                }
                else if (caseFee > 100000000 ){
                    fee_low = 1766000+(caseFee-100000000)*0.01;
                    fee_high = 2866000+(caseFee-100000000)*0.02;
                    fee_mid = (fee_low+fee_high)/2;
                }
                basis = "西安律协2016.3.10发布《关于印发<西安市律师服务收费指导意见>的通知》";
            }break;

//            case "上海":{
//                if (caseFee<=25000){
//                    fee_low=3000;
//                    fee_high=3000;
//                    fee_mid = (fee_low+fee_high)/2;}
//                else if (caseFee > 25000 && caseFee <= 37500){
//                    fee_low = 3000;
//                    fee_high = caseFee*0.12;
//                    fee_mid = (fee_low+fee_high)/2;}
//                    if (caseFee > 37500 && caseFee<=100000){
//                        fee_low=caseFee*0.08;
//                        fee_high=caseFee*0.12;
//                        fee_mid = (fee_low+fee_high)/2;}
//                    else if (caseFee > 100000 && caseFee <= 1000000){
//                        fee_low = 8000+(caseFee-100000)*0.05;
//                        fee_high = 12000+(caseFee-100000)*0.07;
//                        fee_mid = (fee_low+fee_high)/2;
//                    }
//                    else if (caseFee > 1000000 && caseFee <= 10000000){
//                        fee_low = 53000+(caseFee-1000000)*0.03;
//                        fee_high = 75000+(caseFee-1000000)*0.05;
//                        fee_mid = (fee_low+fee_high)/2;
//                    }
//                    else if (caseFee > 10000000 && caseFee <= 100000000){
//                        fee_low = 323000+(caseFee-10000000)*0.01;
//                        fee_high = 525000+(caseFee-10000000)*0.03;
//                        fee_mid = (fee_low+fee_high)/2;
//                    }
//                    else if (caseFee > 100000000 ){
//                        fee_low = 1223000+(caseFee-100000000)*0.005;
//                        fee_high = 3225000+(caseFee-100000000)*0.01;
//                        fee_mid = (fee_low+fee_high)/2;
//                    }
//                    basis="《上海市律师服务收费管理办法》（沪发改规范〔2017〕3号）";
//
//
//
//                }break;

                case "江苏省":{

                    if (caseFee<=10000){
                        fee_low=2500;
                        fee_high=10000;
                        fee_mid = (fee_low+fee_high)/2;}
                    else if (caseFee > 10000 && caseFee <= 100000){
                        fee_low = 2500+(caseFee-10000)*0.06;
                        fee_high = 10000+(caseFee-10000)*0.07;
                        fee_mid = (fee_low+fee_high)/2;
                    }
                    else if (caseFee > 100000 && caseFee <= 500000){
                        fee_low = 7900+(caseFee-100000)*0.05;
                        fee_high = 16300+(caseFee-100000)*0.06;
                        fee_mid = (fee_low+fee_high)/2;
                    }
                    else if (caseFee > 500000 && caseFee <= 1000000){
                        fee_low = 27900+(caseFee-500000)*0.04;
                        fee_high = 40300+(caseFee-500000)*0.05;
                        fee_mid = (fee_low+fee_high)/2;
                    }
                    else if (caseFee > 1000000 && caseFee <= 5000000){
                        fee_low = 47900+(caseFee-1000000)*0.03;
                        fee_high = 65300+(caseFee-1000000)*0.04;
                        fee_mid = (fee_low+fee_high)/2;
                    }
                    else if (caseFee > 5000000 && caseFee <= 10000000){
                        fee_low = 167900+(caseFee-5000000)*0.02;
                        fee_high = 225300+(caseFee-5000000)*0.03;
                        fee_mid = (fee_low+fee_high)/2;
                    }
                    else if (caseFee > 10000000 && caseFee <= 100000000){
                        fee_low = 267900+(caseFee-10000000)*0.01;
                        fee_high = 375300+(caseFee-10000000)*0.02;
                        fee_mid = (fee_low+fee_high)/2;
                    }
                    else if (caseFee > 100000000 ){
                        fee_low = 1167900+(caseFee-100000000)*0.005;
                        fee_high = 2175300+(caseFee-100000000)*0.01;
                        fee_mid = (fee_low+fee_high)/2;
                    }
                    basis="江苏省物价局、司法厅2017.6.30发布《关于明确我省律师服务收费试行标准的通知》附件一：江苏省律师服务收费试行标准表。\n" +
                            "自2017.6.30《关于调整律师服务收费标准的通知》废止，律师服务收费实行市场调节价。";



                }break;
                case "浙江省":{ if (caseFee<=31250){
                    fee_low=2500;
                    fee_high=2500;
                    fee_mid = (fee_low+fee_high)/2;}
                else if (caseFee > 31250 && caseFee <= 41667){
                    fee_low = 2500;
                    fee_high = caseFee*0.18;
                    fee_mid = (fee_low+fee_high)/2;}
               else if (caseFee > 41667 && caseFee<=100000){
                        fee_low=caseFee*0.06;
                        fee_high=caseFee*0.08;
                        fee_mid = (fee_low+fee_high)/2;}

                    else if (caseFee > 100000 && caseFee <= 500000){
                        fee_low = 6000+(caseFee-100000)*0.05;
                        fee_high = 8000+(caseFee-100000)*0.06;
                        fee_mid = (fee_low+fee_high)/2;
                    }
                    else if (caseFee > 500000 && caseFee <= 1000000){
                        fee_low = 26000+(caseFee-500000)*0.04;
                        fee_high = 32000+(caseFee-500000)*0.05;
                        fee_mid = (fee_low+fee_high)/2;
                    }
                    else if (caseFee > 1000000 && caseFee <= 5000000){
                        fee_low = 46000+(caseFee-1000000)*0.03;
                        fee_high = 57000+(caseFee-1000000)*0.04;
                        fee_mid = (fee_low+fee_high)/2;
                    }
                    else if (caseFee > 5000000 && caseFee <= 10000000){
                        fee_low = 166000+(caseFee-5000000)*0.02;
                        fee_high = 217000+(caseFee-5000000)*0.03;
                        fee_mid = (fee_low+fee_high)/2;
                    }

                    else if (caseFee > 10000000 ){
                        fee_low = 266000+(caseFee-10000000)*0.01;
                        fee_high = 367000+(caseFee-10000000)*0.02;
                        fee_mid = (fee_low+fee_high)/2;
                    }
                    basis="自2015.11.15，律师服务收费实行市场调节价。《浙江省律师服务收费标准》（浙价服〔2011〕212号）（已废止，供参考）。";



                }break;
                    case "安徽省":{
                        if (caseFee<=100000){
                            fee_low=500;
                            fee_high=5000;
                            fee_mid = (fee_low+fee_high)/2;}

                        else if (caseFee > 100000 && caseFee <= 1000000){
                            fee_low = 500+(caseFee-100000)*0.025;
                            fee_high = 5000+(caseFee-100000)*0.035;
                            fee_mid = (fee_low+fee_high)/2;
                        }
                        else if (caseFee > 1000000 && caseFee <= 5000000){
                            fee_low = 23000+(caseFee-1000000)*0.015;
                            fee_high = 36500+(caseFee-1000000)*0.025;
                            fee_mid = (fee_low+fee_high)/2;
                        }
                        else if (caseFee > 5000000 && caseFee <= 10000000){
                            fee_low = 83000+(caseFee-5000000)*0.005;
                            fee_high = 136500+(caseFee-5000000)*0.015;
                            fee_mid = (fee_low+fee_high)/2;
                        }


                        else if (caseFee > 10000000 ){
                            fee_low = 108000+(caseFee-10000000 )*0.025;
                            fee_high = 211500+(caseFee-10000000)*0.075;
                            fee_mid = (fee_low+fee_high)/2;
                        }
                        basis="自2016.02.10，律师服务收费实行市场调节价。《安徽省律师服务收费标准》（皖价服〔2003〕236号）（已失效，供参考）。";



                    }break;
            case "天津市":{
                double temp;
                if (caseFee<=10000){
                    temp = 1000;
                }else {
                    temp = 2000 + max(caseFee - 10000, caseFee - 100000) * 0.05 + max(caseFee - 100000, caseFee - 500000) * 0.04 +
                            max(caseFee - 500000, caseFee - 1000000) * 0.03 + max(caseFee - 1000000, caseFee - 10000000) * 0.02 +
                            max(caseFee - 10000000, caseFee - Double.POSITIVE_INFINITY) * 0.01;
                }
//                lyf.setFeemin(temp);
//                lyf.setFeemiddle(temp);
//                lyf.setFeemax(temp);
//                lyf.setBasis("天津律师收费标准");
                fee_low=temp;
                fee_mid=temp;
                fee_high=temp;
                basis="天津律师收费标准";
                break;
            }
            case "北京市":{
                double temp= 3000+max(caseFee-30000,caseFee-100000)*0.1+max(caseFee-100000,caseFee-1000000)*
                        0.06+max(caseFee-1000000,caseFee-10000000)*0.04+max(caseFee-10000000,caseFee-Double.POSITIVE_INFINITY)*0.02;
//                lyf.setFeemin(temp);
//                lyf.setFeemiddle(temp);
//                lyf.setFeemax(temp);
//                lyf.setBasis("北京律师收费标准");
                fee_low=temp;
                fee_mid=temp;
                fee_high=temp;
                basis="北京律师收费标准";
                break;
            }
            case "上海市":{
                double temp1 = 3000+max(caseFee-37500,caseFee-100000)*0.08+max(caseFee-100000,caseFee-1000000)*0.05+
                        max(caseFee-1000000,caseFee-10000000)*0.03+max(caseFee-10000000,caseFee-100000000)*0.01+
                        max(caseFee-100000000,caseFee-Double.POSITIVE_INFINITY)*0.005;
                double temp2 = 3000+max(caseFee-25000,caseFee-100000)*0.12+max(caseFee-100000,caseFee-1000000)*0.07+
                        max(caseFee-1000000,caseFee-10000000)*0.05+max(caseFee-10000000,caseFee-100000000)*0.03+
                        max(caseFee-100000000,caseFee-Double.POSITIVE_INFINITY)*0.01;
                double temp3=(temp1+temp2)/2;
//                lyf.setFeemin(temp1);
//                lyf.setFeemiddle(temp3);
//                lyf.setFeemax(temp2);
//                lyf.setBasis("上海律师收费标准");
                fee_low=temp1;
                fee_mid=temp3;
                fee_high=temp2;
                basis="上海律师收费标准";
                break;
            }
            case "福建省":{
                double temp = 800+max(caseFee-100000,caseFee-500000)*0.04+max(caseFee-500000,caseFee-1000000)*0.03+
                        max(caseFee-1000000,caseFee-5000000)*0.02+max(caseFee-5000000,caseFee-10000000)*0.012+
                        max(caseFee-10000000,caseFee-50000000)*0.007+max(caseFee-50000000,caseFee-Double.POSITIVE_INFINITY)*0.005;
                double temp1 = 6000+max(caseFee-100000,caseFee-500000)*0.04+max(caseFee-500000,caseFee-1000000)*0.03+
                        max(caseFee-1000000,caseFee-5000000)*0.02+max(caseFee-5000000,caseFee-10000000)*0.012+
                        max(caseFee-10000000,caseFee-50000000)*0.007+max(caseFee-50000000,caseFee-Double.POSITIVE_INFINITY)*0.005;
                double temp2=(temp+temp1)/2;
//                lyf.setFeemin(temp);
//                lyf.setFeemiddle(temp2);
//                lyf.setFeemax(temp1);
//                lyf.setBasis("福建律师收费标准");
                fee_low=temp;
                fee_mid=temp2;
                fee_high=temp1;
                basis="福建律师收费标准";
                break;
            }
            case "河北省":{
                double temp= 3000+max(caseFee-37500,caseFee-100000)*0.08+max(caseFee-100000,caseFee-1000000)*
                        0.06+max(caseFee-1000000,caseFee-10000000)*0.04+max(caseFee-10000000,caseFee-Double.POSITIVE_INFINITY)*0.02;
//                lyf.setFeemin(temp);
//                lyf.setFeemiddle(temp);
//                lyf.setFeemax(temp);
//                lyf.setBasis("河北律师收费标准");
                fee_low=temp;
                fee_mid=temp;
                fee_high=temp;
                basis="河北律师收费标准";
                break;
            }
            case "山西省":{
                double temp = 2000+max(caseFee-33333,caseFee-100000)*0.06+max(caseFee-100000,caseFee-500000)*0.05+
                        max(caseFee-500000,caseFee-1000000)*0.04+max(caseFee-1000000,caseFee-5000000)*0.03+
                        max(caseFee-5000000,caseFee-10000000)*0.02+max(caseFee-10000000,caseFee-50000000)*0.015
                        +max(caseFee-50000000,caseFee-Double.POSITIVE_INFINITY)*0.01;
//                lyf.setFeemin(temp);
//                lyf.setFeemiddle(temp);
//                lyf.setFeemax(temp);
//                lyf.setBasis("山西律师收费标准");
                fee_low=temp;
                fee_mid=temp;
                fee_high=temp;
                basis="山西律师收费标准";
                break;
            }
            case "内蒙古自治区":{
                double temp = 1000+max(caseFee-10000,caseFee-100000)*0.05+max(caseFee-100000,caseFee-500000)*0.04+
                        max(caseFee-500000,caseFee-1000000)*0.03+max(caseFee-1000000,caseFee-5000000)*0.02+
                        max(caseFee-5000000,caseFee-10000000)*0.015+max(caseFee-10000000,caseFee-Double.POSITIVE_INFINITY)*0.005;
                double temp1 = 1000+max(caseFee-10000,caseFee-100000)*0.06+max(caseFee-100000,caseFee-500000)*0.05+
                        max(caseFee-500000,caseFee-1000000)*0.04+max(caseFee-1000000,caseFee-5000000)*0.03+
                        max(caseFee-5000000,caseFee-10000000)*0.02+max(caseFee-10000000,caseFee-Double.POSITIVE_INFINITY)*0.01;
                double temp2=(temp+temp1)/2;
//                lyf.setFeemin(temp);
//                lyf.setFeemiddle(temp2);
//                lyf.setFeemax(temp1);
//                lyf.setBasis("内蒙古律师收费标准");
                fee_low=temp;
                fee_mid=temp2;
                fee_high=temp1;
                basis="内蒙古律师收费标准";
                break;
            }
            case "辽宁省":{
                double temp = 2000+max(caseFee-40000,caseFee-100000)*0.05+max(caseFee-100000,caseFee-500000)*0.04+
                        max(caseFee-500000,caseFee-1000000)*0.03+max(caseFee-1000000,caseFee-5000000)*0.02+
                        max(caseFee-5000000,caseFee-10000000)*0.01+max(caseFee-10000000,caseFee-Double.POSITIVE_INFINITY)*0.005;
//                lyf.setFeemin(temp);
//                lyf.setFeemiddle(temp);
//                lyf.setFeemax(temp);
//                lyf.setBasis("辽宁律师收费标准");
                fee_low=temp;
                fee_mid=temp;
                fee_high=temp;
                basis="辽宁律师收费标准";
                break;

            }
        }
        BigDecimal b = new BigDecimal(fee_low);
        fee_low = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
        b = new BigDecimal(fee_mid);
        fee_mid = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
        b = new BigDecimal(fee_high);
        fee_high = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
        return Result.success(new lawyersFeeRequest(fee_low,fee_mid,fee_high,basis));
    }
    public double max(double a,double b){
        double temp=(a>=b?a:b);
        double temp1=(temp>=0?temp:0);
        return temp1<=(a-b)?temp1:(a-b);
    }

}
